<#import "/freemarker/modeltype.ftl" as mt>
<#import "/freemarker/modeltype_entity.ftl" as mte>
<div class="widget" >
	<div class="widget-content">
			<table class="table table-bordered animate2 fadeInUp config">
				<thead>
					<tr>
						<th style="width:120px;">名称</th>
						<th>审批流程(先添加角色才能配置流程，每个改变都必须单独保存)</th>
						<th style="width:100px;">操作</th>
					</tr>
				</thead>
				<tbody id="ListBody" class="add">
					<#assign i = 0>
					<#assign j = 0>
					<#if ((list)?? && list?size gt 0)>
						<#list list as list>
					<tr id="yy_${j}">
						<td>
							<form id="bufrom_${j}">
								<input type="hidden" name="business" value="${(list.business)!''}"/>
								<#if list.business == 1>物品审批流程<#elseif list.business == 2>员工请假流程<#elseif list.business == 3>用车审批流程
								<#elseif list.business == 4>报销审批流程<#elseif list.business == 5>员工离职流程<#elseif list.business == 6>负责人请假离职流程</#if>&nbsp;&nbsp;
								<a href="javascript:;" onclick="javascript: add_processConfig($(this));return false;" class="hr" j="${j}"><font style="color:blue;">[添加]</font></a>
							</form>
						</td>
						<td id="ygh_${j}">
							<form id="rcfrom_${j}">
							<div id="rep_${j}" style="">
								<#if ((list.itemList)?? && list.itemList?size gt 0)>
									<#list list.itemList as item>
											<div class="input-append rep">
												<@mte.Role id='selection2' name='itemList[${i}].rc'  organCode='${cu_organCode}' classname="uniformselect" style="width:120px;" value="${(item.rc)!''}"/>
												<button class="btn btn-xs btn-danger delbtn" type="button" i="${i}" j="${j}" onclick="javascript:delete_processConfig($(this));return false;"><i class="icon-remove"></i></button>
											</div>
											<#if list.itemList?size != item.pc>
												&nbsp;<span><i class="icon-forward"></i><i class="icon-forward"></i></span>
											</#if>
									<#assign i = i + 1/>
									</#list> 
								</#if>
								</div>
							</form>
						</td>
						<td colspan="3" style="text-align: center;">
							<a href="javascript:;" class="btn btn-xs btn-info" onclick="javascript: save_processConfig($(this)); return false;" j="${j}">保&nbsp;存</a>
							<a href="javascript:;" class="btn btn-xs btn-primary" onclick="javascript: sys_load_handle('processConfig');return false;">取&nbsp;消</a>
						</td>
					</tr>
					<#assign j = j + 1/>
					</#list>
				</#if>
				<tr id="yy_${j}" class="yygh">
					<td>
						<form id="bufrom_${j}">
							<input type="hidden" name="itemList[${i}].business"/>
							<select style="width: 120px" id="select_type" name="business">
								<option value="1">物品审批流程</option>
								<option value="2">员工请假审批流程</option>
								<option value="3">用车审批流程</option>
								<option value="4">报销审批流程</option>
								<option value="5">员工离职流程</option>
								<option value="6">负责人请假离职流程</option>
							</select>
							<a href="javascript:;" onclick="javascript: add_processConfig($(this));return false;" class="hr" j="${j}"><font style="color:blue;">[添加]</font></a>
						</form>
					</td>
					<td id="ygh_${j}">
						<form id="rcfrom_${j}">
							<div id="rep_${j}">
								<div class="input-append rep">
									<input type="hidden" name="itemList[${i}].code" value="${(item.code)!''}"/>
									<@mte.Role id='selection_${i}' name='itemList[${i}].rc' organCode='${cu_organCode}' classname="uniformselect" style="width:150px;"/>
									<button class="btn btn-xs btn-danger delbtn" type="button" i="${i}" j="${j}" onclick="javascript:delete_processConfig($(this));return false;"><i class="icon-remove"></i></button>
								</div>
							</div>
							<#assign i = i + 1/>
						</form>
					</td>
					<td colspan="3" style="text-align: center;">
						<a href="javascript:;" class="btn btn-xs btn-info" onclick="javascript: save_processConfig($(this)); return false;" j="${j}">保&nbsp;存</a>
						<a href="javascript:;" class="btn btn-xs btn-primary" onclick="javascript: sys_load_handle('processConfig');return false;">取&nbsp;消</a>
					</td>
				</tr>
				</tbody>
			</table>
	</div>
</div>
<input type="hidden" id="index" value="${i}" />
<div id="temp" style="display:none;">
	<div class="input-append rep">
		<@mte.Role  organCode='${cu_organCode}' classname="uniformselect" style="width:120px;"/>
		<button class="btn btn-xs btn-danger delbtn" type="button" i="${i}" j="${j}" onclick="javascript:delete_processConfig($(this));return false;"><i class="icon-remove"></i></button>
	</div>
</div>

 <script type="text/javascript">
$(function() {
	var blist = eval(${(list1)!''});
	var len = $('#select_type').children().length;
	if (blist != null) {
		for (var i = 1; i <= blist.length; i++) {
			$('#select_type').children().each(function(e){
				if (this.value == blist[i - 1]) {
					$(this).addClass('remove');
				} 
			});
		}
		if (len == blist.length) {
			$('#select_type').parents('.yygh').remove();
		} else {
			$('#select_type').find('.remove').remove();
		} 
	}
}); 

</script>